﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace DEFLib
{
	public static class RegexCache
	{
		private static Dictionary<string, Regex> _cache = new Dictionary<string, Regex>();

		public static Regex Retrieve(string regexStr)
		{
			return RegexCache.Retrieve(regexStr, RegexOptions.None);
		}

		public static Regex Retrieve(string regexStr, RegexOptions options)
		{
			if (!_cache.ContainsKey(regexStr))
			{
				_cache.Add(regexStr, new Regex(regexStr, options));
			}

			return _cache[regexStr];
		}
	}
}
